import React, { FC } from 'react'
import Head from 'next/head'
import { useRouter } from 'next/router'
import { menuItems } from './main-nav'

const DynamicTitle: FC = () => {
  const router = useRouter()
  return (
    <Head>
      <title>
        {`${
          menuItems.find(
            ({ href }) => href !== '/' && router.pathname.includes(href)
          )?.title || '首页'
        } - LEOPEN`}
      </title>
    </Head>
  )
}

export default DynamicTitle
